using System;

namespace BSpec.Specs
{
    public enum DependencyMode
    {
        Mock = 0,
        Real = 1
    }

    public class DependencyContext
    {
        private readonly DependencyMode _dependencyMode;

        public DependencyContext(DependencyMode dependencyMode)
        {
            _dependencyMode = dependencyMode;
        }

        public DependencyMode Mode
        {
            get { return _dependencyMode; }
        }

        public T Resolve<T>(T mockInstance, T realInstance)
        {
            if (Mode == DependencyMode.Mock)
                return mockInstance;
            return realInstance;
        }

        public void RunForMock(Action action)
        {
            if (Mode == DependencyMode.Mock)
                action();
        }
    }
}